package Servlet.MainPage;

import BaseClass.PetInfo;
import DataBase.DataBase;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 鼠标悬停时显示信息窗口
 */
@WebServlet("/ShowItemInfo")
public class ShowItemInfoServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取前端传入的数据
        String pid = req.getParameter("pid");
        PetInfo petInfo = DataBase.getPetInfo(pid);
        String id = petInfo.getPid();
        String petString = "../images/"+id+".jpg";
        resp.setCharacterEncoding("UTF-8");
        resp.getWriter().write(petString);
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}
